<%@ page import="driver.entity.Payfor" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="driver.entity.User" %>
<%@ page import="driver.service.*" %><%--
      Created by IntelliJ IDEA.
      User: LSK
      Date: 2019/10/17
      Time: 19:47
      To change this template use File | Settings | File Templates.
    --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <base target="_blank" />
    <title>西安学车管家</title>
    <link rel="icon" href="asset/logo.ico" type="image/x-icon" />
    <link rel="stylesheet" href="bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="layui/layui/css/layui.css">
</head>
<style>
    body {
        margin: 0;
        padding: 0;
        background-color: rgb(241, 241, 241);
        overflow-x: hidden;
    }

    #search {
        background: #ffffff;
        box-shadow: 2px 0px 15px 1px rgb(231, 231, 231);
    }

    #search li {
        border-bottom: 1px solid rgb(255, 255, 255);
    }

    #search li:hover {
        border-bottom: 1px solid #5FB878;
    }

    #search .navbar-brand:hover,
    #search li a:hover {
        color: #5FB878;
    }

    .container {
        background: #fff;
    }

    img {

        width: 300px;
        height: 200px;
    }

    .div1 {}

    .layui-form-label {
        width: 100px;
    }

    .updataInfo {
        width: 50vw;
        height: 300px;
        margin: 0 auto 40px;
        border-bottom: 1px solid rgb(184, 184, 184);
    }

    .updataInfo .leftImg {
        float: left;
        width: 50%;
    }

    .updataInfo .leftImg span {
        display: block;
        margin-top: 26px;
        margin-left: 6.5vw;
    }

    .updataInfo .leftImg img {
        border-radius: 12px;
        box-shadow: 2px 2px 15px 2px #ccc;
    }

    .updataInfo .rightImg {
        float: left;
        width: 50%;
    }

    .updataInfo .rightImg .Div {
        display: block;
        margin-top: 20px;
    }

    .updataInfo:last-child {
        height: 130px;
        border: none;
    }

    .updataInfo .upSpeed {
        display: block;
        width: 80vw;
        margin: 0 auto;
    }

    .layui-layer,
    .layui-layer-dialog,
    .layui-layer-border,
    .layui-layer-msg,
    .layui-layer-hui {
        top: 10vh;
    }

    #ibox-content {
        opacity: 0;
        transition: all 1.2s ease-in-out;
        margin-top: 60px;
    }

    #btn1,
    #btn2,
    #btn3 {
        display: none;
    }

    #img1,
    #img2,
    #img3,
    #img4{
        border: 1px dashed red;
        border-radius: 10px;
    }

    .Div label input{
        cursor: pointer;
    }
</style>

<body>
    <!--导航条-->
    <nav class="navbar navbar-default " id="search">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a target="_blank" class="navbar-brand" href="index.jsp" data-toggle="tooltip" data-placement="bottom"
                    title="返 回 首 页">
                    <img src="asset/logoBig.png" style="width: 100px;height:38px;margin-top: -7px" alt="">
                </a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">

                </ul>

            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
    <!-- 内容主体 -->
    <div class="container">
        <div>
            <%
                //判断该用户是否提交过保单
                PayforServiceImple_u service=new PayforServiceImple_u();
                String phonenum=request.getParameter("phonenum");
                ArrayList<Payfor> payfors = service.select_all(" ",phonenum);
                //System.out.println(payfors);
                //System.out.println(payfors.isEmpty());
                //System.out.println(payfors.size());
                pageContext.setAttribute("flag",payfors.isEmpty());
                if(!payfors.isEmpty())
                {pageContext.setAttribute("payfors",payfors);}
                //Payfor payfor=null;
                /*if(payfors.size()>0)
                {
                    //不为0则说明该考生提交过表单，这种情况下直接修改标签就行了
                     payfor=payfors.get(0);
                     //以第一次提交的数据为主
                }
                pageContext.setAttribute("payfor",payfor);*/
            %>
            <br>
            <form class="form-horizontal layui-form" method="post">
                <div class="layui-form-item">
                    <!--onsubmit="return check()" -->
                    <h3> 学员信息(被保人)</h3>
                    <br>
                    <!--根据老板的需求，在这里增加学员基本信息的展示-->
                    <%

                        String uid = request.getParameter("uid");
                        //UserService_u service2=new UserServiceImpl_u();
                        //User user = service2.select_user_info(uid);
                        UserService_u service2=new UserServiceImpl_u();
                        User user = service2.select_user_info(uid);
                        //System.out.println(user.toString());
                        pageContext.setAttribute("userinfo",user);
                        //out.print(user.toString());
                    %>
                    <div>
                        <table class="table">
                            <tbody>
                                <tr>
                                    <td>学员姓名:${userinfo.name}</td>
                                    <td>手机号码:${userinfo.phonenum}</td>
                                </tr>
                                <tr>
                                    <td>身份证号码:${userinfo.idcardnum}</td>
                                    <td>保险项目:${userinfo.policyprod}</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">考试时间</label>
                        <div class="layui-input-inline">
                            <input name="examtime" id="examtime" type="text" name="date" id="date" lay-verify="date"
                                placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">考试地点</label>
                        <div class="layui-input-inline">
                            <select id="examadd" name="examadd">
                                <option></option>
                                <option value="西安市">西安市</option>
                                <option value="咸阳市">咸阳市</option>
                                <option value="宝鸡市">宝鸡市</option>
                                <option value="渭南市">渭南市</option>
                                <option value="铜川市">铜川市</option>
                                <option value="榆林市">榆林市</option>
                                <option value="延安市">延安市</option>
                                <option value="汉中市">汉中市</option>
                                <option value="安康市">安康市</option>
                                <option value="商洛市">商洛市</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">理赔项目</label>
                        <div class="layui-input-inline">
                            <select id="payitem" name="payitem">
                                <option></option>
                                <option value="科目一">科目一</option>
                                <option value="科目二">科目二</option>
                                <option value="科目三">科目三</option>
                                <option value="科目四">科目四</option>
                            </select>
                        </div>
                    </div>
                    <br>
                    <div class="layui-inline">
                        <div class="layui-input-inline" style="width: 292px">
                            <label class="layui-form-label">122密码</label>
                            <div class="layui-input-block">
                                <input type="text" name="pass122" id="pass122" placeholder="122密码" autocomplete="off"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="ibox-content" id="ibox-content">
                    <hr>
                    <h3>理赔资料上传</h3>
                    <div class="updataInfo">
                        <div class="leftImg">
                            <!--img src="img/zhengmian.png">-->
                            <img src="img/zhengmian1.png">
                            <br>
                            <span>身份证正面图片</span>
                        </div>
                        <div class="rightImg">
                            <img id="img1" src="img/nomo.png" alt="身份证正面照片"> <input id="in1" name="idcard1"
                                style="display: none">
                            <input id="in2" name="idcard2" style="display: none">
                            <input id="in3" name="unpass" style="display: none">
                            <input id="in4" name="info" style="display: none">
                            <div class="Div">
                                <label><input id="idcard1" type="file"
                                        onchange="(()=>{document.getElementById('btn1').onclick();console.log('ok')})()"></label>
                                <button class="btn btn-success " id="btn1" type="button">上传身份证正面</button></div>
                        </div>
                    </div>
                    <div class="updataInfo">
                        <div class="leftImg">
                            <img src="img/fanmian.png">
                            <br>
                            <span>身份证反面图片</span>
                        </div>
                        <div class="rightImg">
                            <img id="img2" src="img/nomo.png" alt="身份证反面照片">
                            <div class="Div">
                                <label><input id="idcard2" type="file"
                                        onchange="(()=>{document.getElementById('btn2').onclick();console.log('ok')})()"></label>
                                <button class="btn btn-success " id="btn2" type="button">上传身份证正面</button></div>
                        </div>
                    </div>
                    <div class="updataInfo">
                        <div class="leftImg">
                            <img src="img/un.png">
                            <br>
                            <span>考试为通过凭证(考试成绩单照片)</span>
                        </div>
                        <div class="rightImg">
                            <img id="img3" src="img/nomo.png" alt="考试未通过凭证">
                            <div class="Div">
                                <label><input id="unpass" type="file"
                                        onchange="(()=>{document.getElementById('btn3').onclick();console.log('ok')})()"></label>
                                <button class="btn btn-success " id="btn3" type="button">上传考试未通过凭证</button></div>
                        </div>
                    </div>

                    <!---->
                    <div class="updataInfo">
                        <div class="leftImg">
                            <img src="img/info.JPG">
                            <br>
                            <span>学员基本信息(12123截图)</span>
                        </div>
                        <div class="rightImg">
                            <img id="img4" src="img/nomo.png" alt="12123学员基本信息">
                            <div class="Div">
                                <label><input id="info" type="file"
                                              onchange="(()=>{document.getElementById('btn4').onclick();console.log('ok')})()"></label>
                                <button class="btn btn-success " id="btn4" type="button" style="display: none">上传身份证正面</button></div>
                        <br/>
                        </div>
                    </div>



                    <div class="updataInfo">
                       <!-- <div class="upSpeed">
                            <p>上传速度【仅供参考】</p>-->
                            <!--上传速度：<progress id="progressBar" value="0" max="100" style="width: 300px;"></progress>
                            <span id="percentage"></span><span id="time"></span>
                            <br /><br /> <button id="btn4" class="btn btn-success " type="button"
                                onclick="check()">提交按钮</button>
                        </div>-->
                            <div class="upSpeed">
                                <!--<p>上传速度【仅供参考】</p>--><button style="float: left;margin-left: 5vw" id="btn5" class="btn btn-success "
                                                                type="button" onclick="check()">提交按钮</button>
                                <div style="float: left;margin-left: 10vw;margin-top: 8px">
                                    上传速度：<progress id="progressBar" value="0" max="100"
                                                   style="width: 300px;"></progress>
                                    <span id="percentage"></span><span id="time"></span>
                                </div>

                            </div>
                        </div>

                    </div>
            </form>
        </div>
        <div id="div1" style="margin-left:20%;">
            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-8">
                </div>
            </div>
            <div class="layui-layer layui-layer-dialog layui-layer-border layui-layer-msg layui-layer-hui"
                id="layuiMyself" type="dialog" times="6" showtime="60000" contype="string"
                style="display:none;z-index: 19891020; width: 360px;  top: 30vh; left:40vw; background-color: rgba(0, 150, 136, 0.9);">
                <div id=" " class="layui-layer-content">
                    <div class="" id="layui-layer27" type="dialog" times="60" showtime="60000" contype="string"
                        style="z-index: 19891041; top: -20vh; left: 290px;">
                        <div id="" class="layui-layer-content">考试时间、考试地点、理赔项目、122密码均不能为空，请重新录入</div>
                        <span class="layui-layer-setwin"></span>
                    </div>
                </div>
                <div class="layui-layer-btn layui-layer-btn-"><a target="_blank" class="layui-layer-btn0"
                        id="layuiMysure">确认</a></div>
            </div>
        </div>

        <canvas id="canvas" style="display: none"></canvas>
        <script src="bootstrap/dist/js/jquery-3.4.1.min.js"></script>
        <script src="bootstrap/dist/js/bootstrap.min.js"></script>
        <script src="bootstrap/dist/js/layui/layui.all.js"></script>


        <script  type="text/javascript">
            layui.use(['form', 'layedit', 'laydate'], function () {
                var form = layui.form,
                    layer = layui.layer,
                    layedit = layui.layedit,
                    laydate = layui.laydate;

                //日期
                laydate.render({
                    elem: '#examtime'
                });
                laydate.render({
                    elem: '#date1'
                });

                //创建一个编辑器

            });
        </script>
        <script  type="text/javascript">
            layuiMysure.onclick = function () {
                layuiMyself.style.display = "none";
            }

            function check() {
                //前端表单认证
                //照片可以不上传
                if ($("#examtime").val().length === 0 || $("#examadd").val().length === 0 || $("#payitem").val()
                    .length === 0 || $("#pass122").val().length === 0) {
                    layuiMyself.style.display = "block";
                    console.log($("#examtime").val().length + '/' + $("#examadd").val().length + '/' + $(
                            "#payitem")
                        .val().length + '/' + $("#pass122").val().length);
                    $("#layuiMyself").find('.layui-layer-content').eq(0).html("输入不能为空，请重新输入！");
                    $('.layui-layer-msg').css('backgroundColor', 'rgba(0,150,136,0.84)');
                    setTimeout(function () {
                        $("#layuiMyself").css("display", "none");
                    }, 20000);
                    return false;
                } else {
                    fun();
                }
                //return true;
            }
        </script>
        <%
//session.getAttribute("id");
%>
        <script  type="text/javascript">
            $(function () {
                //入口函数
                //不应该使用payfors.size(),应该先进行非空判断
                if (${
                        !flag
                    }) {
                    console.log("该用户不是第一次提交考试未通过理赔申请！");
                    //把数据库获取到的第一条数据写到输入框里面
                    $("#pass122").val('${payfors.get(0).pass122}');
                    $("#img1").attr('src', '${payfors.get(0).idcard1_src}');
                    $("#img2").attr('src', '${payfors.get(0).idcard2_src}');
                    $("#img4").attr('src','${payfors.get(0).info_src}');


                    //2019.10.23 16:44
                    //提交表单使用
                    $("#in1").val('${payfors.get(0).idcard1_src}');
                    $("#in2").val('${payfors.get(0).idcard2_src}');
                    $("#in4").val('${payfors.get(0).info_src}');
                }

                else {
                    console.log("该用户是第一次提交考试未通过理赔申请！");
                    $("#img1").attr('src', 'img/nomo.jpg');
                    $("#img2").attr('src', 'img/nomo.jpg');
                    $("#unpass").attr('src', 'img/nomo.jpg');
                    $("#info").attr('src','img/nomo.jpg');
                    //什么都不做
                }

            });
        </script>

        <script type="text/javascript">
            $(function () {
                douploadphoto("btn1", "idcard1", "#img1", "#in1");
                douploadphoto("btn2", "idcard2", "#img2", "#in2");
                douploadphoto("btn3", "unpass", "#img3", "#in3");
                douploadphoto("btn4","info","#img4","#in4");

                function douploadphoto(btn_id, file_id, img_id, in_id) {
                    document.getElementById(btn_id).onclick = function () {
                        console.log("你点我干什么" + btn_id);
                        UpladFile();
                    };

                    function photoCompress(file, w, objDiv) {

                        var ready = new FileReader();
                        /*开始读取指定的Blob对象或File对象中的内容. 当读取操作完成时,readyState属性的值会成为DONE,如果设置了onloadend事件处理程序,则调用之.同时,result属性中将包含一个data: URL格式的字符串以表示所读取文件的内容.*/
                        ready.readAsDataURL(file);
                        ready.onload = function () {
                            var re = this.result;
                            canvasDataURL(re, w, objDiv)
                        }
                    }

                    function canvasDataURL(path, obj, callback) {
                        var img = new Image();
                        img.src = path;
                        img.onload = function () {
                            var that = this;
                            // 默认按比例压缩
                            var w = that.width,
                                h = that.height,
                                scale = w / h;
                            w = obj.width || w;
                            h = obj.height || (w / scale);
                            var quality = 0.7; // 默认图片质量为0.7
                            //生成canvas
                            var canvas = document.createElement('canvas');
                            var ctx = canvas.getContext('2d');
                            // 创建属性节点
                            var anw = document.createAttribute("width");
                            anw.nodeValue = w;
                            var anh = document.createAttribute("height");
                            anh.nodeValue = h;
                            canvas.setAttributeNode(anw);
                            canvas.setAttributeNode(anh);
                            ctx.drawImage(that, 0, 0, w, h);
                            // 图像质量
                            if (obj.quality && obj.quality <= 1 && obj.quality > 0) {
                                quality = obj.quality;
                            }
                            // quality值越小，所绘制出的图像越模糊
                            var base64 = canvas.toDataURL('image/jpeg', quality);
                            // 回调函数返回base64的值
                            callback(base64);
                        }
                    }
                    /**
                     * 将以base64的图片url数据转换为Blob
                     * @param urlData
                     *            用url方式表示的base64图片数据
                     */
                    function convertBase64UrlToBlob(urlData) {
                        var arr = urlData.split(','),
                            mime = arr[0].match(/:(.*?);/)[1],
                            bstr = atob(arr[1]),
                            n = bstr.length,
                            u8arr = new Uint8Array(n);
                        while (n--) {
                            u8arr[n] = bstr.charCodeAt(n);
                        }
                        return new Blob([u8arr], {
                            type: mime
                        });
                    }


                    var xhr;
                    //上传文件方法
                    function UpladFile() {

                        //修改参数
                        var fileObj = document.getElementById(file_id).files[0]; // js 获取文件对象



                        var url = "${pageContext.request.contextPath}/upload"; // 接收上传文件的后台地址

                        var form = new FormData(); // FormData 对象

                        if (fileObj.size / 1024 > 1025) { //大于1M，进行压缩上传
                            photoCompress(fileObj, {
                                quality: 0.2
                            }, function (base64Codes) {
                                //console.log("压缩后：" + base.length / 1024 + " " + base);
                                var bl = convertBase64UrlToBlob(base64Codes);
                                form.append("file", bl, "file_" + Date.parse(new Date()) +
                                    ".jpg"); // 文件对象
                                xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
                                xhr.open("post", url,
                                    true); //post方式，url为服务器请求地址，true 该参数规定请求是否异步处理。
                                xhr.onload = uploadComplete; //请求完成
                                xhr.onerror = uploadFailed; //请求失败

                                xhr.upload.onprogress = progressFunction; //【上传进度调用方法实现】
                                xhr.upload.onloadstart = function () { //上传开始执行方法
                                    ot = new Date().getTime(); //设置上传开始时间
                                    oloaded = 0; //设置上传开始时，以上传的文件大小为0
                                };

                                xhr.send(form); //开始上传，发送form数据
                            });
                        } else { //小于等于1M 原图上传
                            form.append("file", fileObj); // 文件对象
                            xhr = new XMLHttpRequest(); // XMLHttpRequest 对象
                            xhr.open("post", url, true); //post方式，url为服务器请求地址，true 该参数规定请求是否异步处理。
                            xhr.onload = uploadComplete; //请求完成
                            xhr.onerror = uploadFailed; //请求失败

                            xhr.upload.onprogress = progressFunction; //【上传进度调用方法实现】
                            xhr.upload.onloadstart = function () { //上传开始执行方法
                                ot = new Date().getTime(); //设置上传开始时间
                                oloaded = 0; //设置上传开始时，以上传的文件大小为0
                            };

                            xhr.send(form); //开始上传，发送form数据
                        }
                    }

                    //上传成功响应
                    function uploadComplete(evt) {
                        //服务断接收完文件返回的结果

                        //var data = JSON.parse(evt.target.responseText);
                        var data = evt.target.responseText;
                        //忽略判断，直接返回后端返回的值
                        console.log(data);

                        $(img_id).attr('src', data);
                        $(in_id).val(data);
                        /*if(data.success) {
                            alert("上传成功！");
                        }else{
                            alert("上传失败！");
                        }*/

                    }
                    //上传失败
                    function uploadFailed(evt) {
                        // alert("上传失败！");


                        layui.use('layer', function () {
                            var $ = layui.jquery,
                                layer = layui.layer;

                            layer.msg("上传失败", {
                                time: 20000, //20s后自动关闭
                                btn: ['确认']
                            });
                            $('.layui-layer-msg').css('backgroundColor', 'rgba(0,150,136,0.84)');

                        });
                    }
                    //取消上传
                    function cancleUploadFile() {
                        xhr.abort();
                    }

                    //上传进度实现方法，上传过程中会频繁调用该方法
                    function progressFunction(evt) {
                        var progressBar = document.getElementById("progressBar");
                        var percentageDiv = document.getElementById("percentage");
                        // event.total是需要传输的总字节，event.loaded是已经传输的字节。如果event.lengthComputable不为真，则event.total等于0
                        if (evt.lengthComputable) { //
                            progressBar.max = evt.total;
                            progressBar.value = evt.loaded;
                            percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%";
                        }
                        var time = document.getElementById("time");
                        var nt = new Date().getTime(); //获取当前时间
                        var pertime = (nt - ot) / 1000; //计算出上次调用该方法时到现在的时间差，单位为s
                        ot = new Date().getTime(); //重新赋值时间，用于下次计算
                        var perload = evt.loaded - oloaded; //计算该分段上传的文件大小，单位b
                        oloaded = evt.loaded; //重新赋值已上传文件大小，用以下次计算
                        //上传速度计算
                        var speed = perload / pertime; //单位b/s
                        var bspeed = speed;
                        var units = 'b/s'; //单位名称
                        if (speed / 1024 > 1) {
                            speed = speed / 1024;
                            units = 'k/s';
                        }
                        if (speed / 1024 > 1) {
                            speed = speed / 1024;
                            units = 'M/s';
                        }
                        speed = speed.toFixed(1);
                        //剩余时间
                        var resttime = ((evt.total - evt.loaded) / bspeed).toFixed(1);
                        time.innerHTML = '，速度：' + speed + units + '，剩余时间：' + resttime + 's';
                        if (bspeed === 0) time.innerHTML = '上传已取消';
                    }





                }
            })
        </script>
        <!--2019-10-21-->
        <script>
            /* 鼠标特效 */
            var a_idx = 0;
            jQuery(document).ready(function ($) {
                $("body").click(function (e) {
                    var a = ["富强", "民主", "文明", "和谐", "自由", "平等", "公正", "法治", "爱国", "敬业", "诚信",
                        "友善"
                    ];
                    var $i = $("<span/>").text(a[a_idx]);
                    a_idx = (a_idx + 1) % a.length;
                    var x = e.pageX,
                        y = e.pageY;
                    $i.css({
                        "z-index": 9999999999999999999999999999999999999999,
                        "top": y - 20,
                        "left": x,
                        "position": "absolute",
                        "font-weight": "bold",
                        "color": "#ff6651"
                    });
                    $("body").append($i);
                    $i.animate({
                            "top": y - 180,
                            "opacity": 0
                        },
                        1500,
                        function () {
                            $i.remove();
                        });
                });
            });
            //alert("用户名不存在，请联系管理员");
        </script>

        <script src="${pageContext.request.contextPath}/Lskjs/lskjs.js" type="text/javascript">

        </script>
        <script  type="text/javascript">
            $(function () {
                $('[data-toggle="tooltip"]').tooltip();
                //加载页面后产生的动画
                $('#ibox-content').css({
                    "transform": "translateY(-50px)",
                    "opacity": "1"
                });
            })
            function fun() {
                //使用$.ajax()发送异步请求
                $.ajax({
                    url: "${pageContext.request.contextPath}/doAddPayfor?uid=<%=request.getParameter("uid")%>&sid=<%=request.getParameter("sid")%>", // 请求路径
                    type: "POST", //请求方式
                    data: {
                        "examtime": $("#examtime").val(),
                        "examadd": $("#examadd").val(),
                        "payitem": $("#payitem").val(),
                        "pass122": $("#pass122").val(),
                        "idcard1": $("#in1").val(),
                        "idcard2": $("#in2").val(),
                        "unpass": $("#in3").val(),
                        "info":$("#in4").val()

                    },
                    success: function (data) {
                        $("#layuiMyself").css("display", "block");
                        $("#layuiMyself").find('.layui-layer-content').eq(0).html("数据请求成功，结果:" + data);
                        console.log("数据库请求成功");

                    }, //响应成功后的回调函数
                    error: function () {
                        $("#layuiMyself").css("display", "block");
                        $("#layuiMyself").find('.layui-layer-content').eq(0).html("请求数据发生错误！");
                        console.log("数据库请求错误");
                        setTimeout(function () {
                            $("#layuiMyself").css("display", "none");
                        }, 20000)
                    }, //表示如果请求响应出现错误，会执行的回调函数

                    dataType: "text" //设置接受到的响应数据的格式
                });
            }
        </script>
</body>

</html>